<?php
/**
 * Created by cmb_weixin.master.
 * File: ProductOrderReserve.php
 * User: xuewl
 * Date: 2017/12/20
 * Time: 00:38
 */

namespace app\product\model;
use app\common\library\Model;

class ProductOrderReserve extends Model
{
    protected $append = [
        'result_name'
    ];

    public function getResultNameAttr($value, $data) {
        $config = config('product.product_order_reserve_field_result');
        return $config[$data['result']];
    }

    public function product() {
        return $this->hasOne("\\app\\product\\model\\Product", "id", "product_id");
    }

    public function orderInfo() {
        return $this->hasOne("app\\product\\model\\ProductOrder", "sn", "order_sn");
    }

    public function orderUserInfo() {
        return $this->hasOne("app\\user\\model\\User", "id", 'order_uid');
    }

    public function customerUserInfo() {
        return $this->hasOne("app\\user\\model\\User", "id", "customer_id");
    }

}